use"/Users/bei/Documents/Seafile/ICT_and_armed_Conflict/Rcode/replication2023/paperdf2.dta",clear
use"ICT_and_armed_Conflict/Rcode/replication2023/paperdf2.dta",clear
xtset id year

************

**生成截尾变量（稳健性检验部分）**

winsor conflict_dum1, gen(conflict_dum1_w) p(0.01)
winsor conflict1, gen(conflict1_w) p(0.01)
winsor internet1, gen(internet1_w) p(0.01)
winsor log_pop, gen(log_pop_w) p(0.01)
winsor log_gdpp, gen(log_gdpp_w) p(0.01)
winsor military_expense, gen(military_expense_w) p(0.01)
winsor hisdum1, gen(hisdum1_w) p(0.01)
winsor wgi5, gen(wgi5_w) p(0.01)
winsor polity2, gen(polity2_w) p(0.01)
winsor excluded, gen(excluded_w) p(0.01)
winsor oil, gen(oil_w) p(0.01)
winsor cellphone, gen(cellphone_w) p(0.01)

gen internet2_w = internet1_w*internet1_w
gen cellphone2_w = cellphone_w*cellphone_w



*** 表1 检验核心假设
*****冲突是否发生（logit）*******
*********************************
xtlogit  conflict_dum1 l.internet1 l.internet2 l.log_pop l.log_gdpp l.military_expense l.hisdum1 l.wgi5 l.polity2 l.excluded l.oil , fe
est store m1

xtlogit  conflict_dum1 l.internet1 l.internet2 l.log_pop l.log_gdpp l.military_expense l.hisdum1 l.wgi5 l.polity2 l.excluded l.oil i.year, fe
est store m2

*** 负二项

xtnbreg conflict1 l.internet1 l.internet2 l.log_pop l.log_gdpp l.military_expense l.hisdum1 l.wgi5 l.polity2 l.excluded l.oil, fe 
est store m3


xtnbreg conflict1 l.internet1 l.internet2 l.log_pop l.log_gdpp l.military_expense l.hisdum1 l.wgi5 l.polity2 l.excluded l.oil i.year, fe
est store m4

*混合效应
menbreg conflict1 l.internet1 l.internet2 l.log_pop l.log_gdpp l.military_expense l.hisdum1 l.wgi5 l.polity2 l.excluded l.oil || id: 
est store m5

menbreg conflict1 l.internet1 l.internet2 l.log_pop l.log_gdpp l.military_expense l.hisdum1 l.wgi5 l.polity2 l.excluded l.oil || id: || year:
est store m6


esttab m* using tab1new.rtf, ///
mtitles(main results) ///
title(Table 1. conflict dummy (1996-2018, UCDP-GED) (Logit models)) ///
append b(4) se(4) stats(N aic bic) star(* 0.10 ** 0.05 *** 0.01)  nogaps



*** 表2 检验竞争性假设

xtlogit  conflict_dum1 l.internet1 l.log_pop l.log_gdpp l.military_expense l.hisdum1 l.wgi5 l.polity2 l.excluded l.oil , fe
est store mc1

xtlogit  conflict_dum1 l.internet1 l.log_pop l.log_gdpp l.military_expense l.hisdum1 l.wgi5 l.polity2 l.excluded l.oil i.year, fe
est store mc2

*** 负二项

xtnbreg conflict1 l.internet1 l.log_pop l.log_gdpp l.military_expense l.hisdum1 l.wgi5 l.polity2 l.excluded l.oil, fe 
est store mc3


xtnbreg conflict1 l.internet1 l.log_pop l.log_gdpp l.military_expense l.hisdum1 l.wgi5 l.polity2 l.excluded l.oil i.year, fe
est store mc4

*混合效应
menbreg conflict1 l.internet1 l.log_pop l.log_gdpp l.military_expense l.hisdum1 l.wgi5 l.polity2 l.excluded l.oil || id: 
est store mc5

menbreg conflict1 l.internet1 l.log_pop l.log_gdpp l.military_expense l.hisdum1 l.wgi5 l.polity2 l.excluded l.oil || id: || year:
est store mc6


*esttab mod*, b(4) se(4) stats(N aic bic) star(* 0.10 ** 0.05 *** 0.01) compress nogap

esttab mc* using tab2new.rtf, ///
mtitles(main results-competitive assump) ///
title(Table 2. conflict dummy (1996-2018, UCDP-GED) (Logit models)(competitive assumption)) ///
append b(4) se(4) stats(N aic bic) star(* 0.10 ** 0.05 *** 0.01)  nogaps


**********附表2-3

**描述性表格**
asdoc summarize conflict_dum1 internet1 log_pop log_gdpp military_expense hisdum1 wgi5 polity2 excluded oil, detail save(disctabnew.doc) append

**变量相关性**
asdoc pwcorr conflict_dum1 l.internet1  l.log_pop l.log_gdpp l.military_expense l.hisdum1 l.wgi5 l.polity2 l.excluded l.oil , detail save(disctab2new.doc) append


**附表4.手机***

**3.手机无平方项**
xtlogit conflict_dum1 l. cellphone l.log_pop l.log_gdpp l.military_expense l.hisdum1 l.wgi5 l.polity2 l.excluded l.oil i.year if year<2010, fe
est store cm1

**4.手机平方项**
xtlogit conflict_dum1 l. cellphone l. cellphone2 l.log_pop l.log_gdpp l.military_expense l.hisdum1 l.wgi5 l.polity2 l.excluded l.oil i.year if year<2010, fe
est store cm2

esttab cm1 cm2 using aptab4.rtf



*********************************
*****（缩尾各1.5%）*******
** 附表5.
*********************************


**1.logit-互联网**
xtlogit conflict_dum1_w l. internet1_w l. log_pop_w l. log_gdpp_w l. military_expense_w l. hisdum1_w l. wgi5_w l. polity2_w l. excluded_w l. oil_w i.year, fe
est store wm1


**2.logit-互联网平方项**
xtlogit conflict_dum1_w l. internet1_w l. internet2_w l. log_pop_w l. log_gdpp_w l. military_expense_w l. hisdum1_w l. wgi5_w l. polity2_w l. excluded_w l. oil_w i.year, fe
est store wm2

**3. 个体固定负二项**
xtnbreg conflict1_w l. internet1_w l. internet2_w l. log_pop_w l. log_gdpp_w l. military_expense_w l. hisdum1_w l. wgi5_w l. polity2_w l. excluded_w l. oil_w, fe
est store wm3

**4. 双向固定负二项**
xtnbreg conflict1_w l. internet1_w l. internet2_w l. log_pop_w l. log_gdpp_w l. military_expense_w l. hisdum1_w l. wgi5_w l. polity2_w l. excluded_w l. oil_w i.year, fe
est store wm4

**5. 混合效应负二项**
menbreg conflict1_w l. internet1_w l. internet2_w l. log_pop_w l. log_gdpp_w l. military_expense_w l. hisdum1_w l. wgi5_w l. polity2_w l. excluded_w l. oil_w || id: 
est store wm5

**6. 混合效应负二项**
menbreg conflict1_w l. internet1_w l. internet2_w l. log_pop_w l. log_gdpp_w l. military_expense_w l. hisdum1_w l. wgi5_w l. polity2_w l. excluded_w l. oil_w || id: || year:
est store wm6


esttab wm* using aptab5.rtf



*********************************
*****（取对数）*******
**附表6
*********************************

**1.个体时间固定效应-互联网**
xtlogit conflict_dum1 l. log_internet1 l. log_pop l. log_gdpp l. military_expense l. hisdum1 l. wgi5 l. polity2 l. excluded l. oil i.year, fe
est store am1


**2.个体时间固定效应-互联网**
xtlogit conflict_dum1 l. log_internet1 l. log_internet2 l. log_pop l. log_gdpp l. military_expense l. hisdum1 l. wgi5 l. polity2 l. excluded l. oil i.year, fe
est store am2

*** 负二项
xtnbreg conflict1 l. log_internet1 l. log_internet2 l.log_pop l.log_gdpp l.military_expense l.hisdum1 l.wgi5 l.polity2 l.excluded l.oil, fe 
est store am3

xtnbreg conflict1 l. log_internet1 l. log_internet2 l.log_pop l.log_gdpp l.military_expense l.hisdum1 l.wgi5 l.polity2 l.excluded l.oil i.year, fe
est store am4

*混合效应
menbreg conflict1 l. log_internet1 l. log_internet2 l.log_pop l.log_gdpp l.military_expense l.hisdum1 l.wgi5 l.polity2 l.excluded l.oil || id: 
est store am5

menbreg conflict1 l. log_internet1 l. log_internet2 l.log_pop l.log_gdpp l.military_expense l.hisdum1 l.wgi5 l.polity2 l.excluded l.oil || id: || year:
est store am6

esttab am* using aptab6.rtf


*********************************
*******逆向因果关系*******
**附表7
gen conflict3hist = 1 if l.conflict_dum1 == 1 | l2.conflict_dum1 == 1 | l3.conflict_dum1 == 1
replace conflict3hist = 0 if conflict3hist ==. 


xtreg internet1  conflict3hist log_pop log_gdpp military_expense hisdum1 wgi5 polity2 excluded oil i.year, fe
est store r1
xtreg internet1  l.conflict_dum1 log_pop log_gdpp military_expense hisdum1 wgi5 polity2 excluded oil i.year, fe
est store r2
xtreg internet1  l2.conflict_dum1 log_pop log_gdpp military_expense hisdum1 wgi5 polity2 excluded oil i.year, fe
est store r3
xtreg internet1  l3.conflict_dum1 log_pop log_gdpp military_expense hisdum1 wgi5 polity2 excluded oil i.year, fe
est store r4

esttab r* using reverse.rtf, replace ///
mtitles(lag1-year lag2-year lag3-year past3-year) ///
title(Table 4. reverse causation (1996-2018, UCDP-GED) (OLS models)) ///
 b(3) se(3) stats(N aic bic) star(* 0.10 ** 0.05 *** 0.01)  nogaps



